/** init domain config */
import './config'

import Vue from 'vue'
import App from './App.vue'
import Storage from 'vue-ls'  
import router from './router'
import store from './store/'
import { VueAxios } from '@/utils/request'
import scroll from 'vue-seamless-scroll'

import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'

require('@jeecg/antd-online-mini')
require('@jeecg/antd-online-mini/dist/OnlineForm.css')

import Antd, { version } from 'ant-design-vue'
// console.log('ant-design-vue version:', version)

import Viser from 'viser-vue'
import 'ant-design-vue/dist/antd.less' // or 'ant-design-vue/dist/antd.less'

import '@/permission' // permission control
import '@/utils/filter' // base filter
import Print from 'vue-print-nb-jeecg'
/*import '@babel/polyfill'*/
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import SSO from '@/cas/sso.js'
import animated from 'animate.css'

import moment from 'moment'
import 'moment/locale/zh-cn'
moment.locale('zh-cn') //设置语言 或 moment.lang('zh-cn'); 

import '@/assets/css/index.css'
// 将自动注册所有组件为全局组件
import dataV from '@jiaminghi/data-view'

Vue.use(dataV)

Vue.use(animated)
import {
  ACCESS_TOKEN,
  DEFAULT_COLOR,
  DEFAULT_THEME,
  DEFAULT_LAYOUT_MODE,
  DEFAULT_COLOR_WEAK,
  SIDEBAR_TYPE,
  DEFAULT_FIXED_HEADER,
  DEFAULT_FIXED_HEADER_HIDDEN,
  DEFAULT_FIXED_SIDEMENU,
  DEFAULT_CONTENT_WIDTH_TYPE,
  DEFAULT_MULTI_PAGE,
} from '@/store/mutation-types'
import config from '@/defaultSettings'

import JDictSelectTag from './components/dict/index.js'
import hasPermission from '@/utils/hasPermission'
import vueBus from '@/utils/vueBus'
import JeecgComponents from '@/components/jeecg/index'
import '@/assets/less/JAreaLinkage.less'
import VueAreaLinkage from 'vue-area-linkage'
import '@/components/jeecg/JVxeTable/install'
import '@/components/JVxeCells/install'
// ElementUI 放置最前，Antd放置于后
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// For IM add by nbacheng 2022-08-17
import { dateStr, formatDateTime } from '@/utils/im/ChatUtils.js'
if (process.env.VUE_APP_MODE === 'web') {
  Vue.prototype.winControl = require('@/mode/webControl').default
}
// For erp add by nbacheng 2022-08-25
import utils from '@/utils/utils'
// for formdesigner  add by nbchang 2022-09-03
import formDesigner from '@/components/formdesigner/components/index'
// import Print from 'vue-print-nb'
// console.log('Print', Print)
// Vue.use(Print);
import SChart from '@/components/VChart.vue'
Vue.component('s-chart', SChart)

// For IM add by nbacheng 2022-08-17
Vue.use(ElementUI)
Vue.use(ViewUI)
// for formdesigner  add by nbchang 2022-09-03
Vue.use(formDesigner)
// 表单验证
import { rules } from '@/utils/rules'
Vue.prototype.rules = rules
Vue.config.productionTip = false
// IM
Vue.prototype.formatDateTime = formatDateTime
Vue.prototype.dateStr = dateStr
// For erp add by nbacheng 2022-08-25
Vue.prototype.$utils = utils
Vue.prototype.$moment = moment //挂载到当前vue实例对象

Vue.use(Storage, config.storageOptions)
Vue.use(Antd)
Vue.use(VueAxios, router)
Vue.use(Viser)
Vue.use(hasPermission)
Vue.use(JDictSelectTag)
Vue.use(Print)
Vue.use(preview)
Vue.use(vueBus)
Vue.use(JeecgComponents)
Vue.use(VueAreaLinkage)
Vue.use(scroll)
SSO.init(() => {
  main()
})
function main() {
  new Vue({
    router,
    store,
    mounted() {
      store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, true))
      store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.navTheme))
      store.commit('TOGGLE_LAYOUT_MODE', Vue.ls.get(DEFAULT_LAYOUT_MODE, config.layout))
      store.commit('TOGGLE_FIXED_HEADER', Vue.ls.get(DEFAULT_FIXED_HEADER, config.fixedHeader))
      store.commit('TOGGLE_FIXED_SIDERBAR', Vue.ls.get(DEFAULT_FIXED_SIDEMENU, config.fixSiderbar))
      store.commit('TOGGLE_CONTENT_WIDTH', Vue.ls.get(DEFAULT_CONTENT_WIDTH_TYPE, config.contentWidth))
      store.commit('TOGGLE_FIXED_HEADER_HIDDEN', Vue.ls.get(DEFAULT_FIXED_HEADER_HIDDEN, config.autoHideHeader))
      store.commit('TOGGLE_WEAK', Vue.ls.get(DEFAULT_COLOR_WEAK, config.colorWeak))
      store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.primaryColor))
      store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
      store.commit('SET_MULTI_PAGE', Vue.ls.get(DEFAULT_MULTI_PAGE, config.multipage))
    },
    render: (h) => h(App),
  }).$mount('#app')
}
